package com.qk.mapper;

import com.qk.dto.UserDto;
import com.qk.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    List<User> listAll(UserDto userDto);

  /*  @Delete("delete from user where id=#{id}")
    void deleleByid(Integer id);*/
    @Insert("insert into user(id,username,password,name,phone,email,gender,status,dept_id,role_id,image,remark,create_time,update_time) values(#{id},#{username},#{password},#{name},#{phone},#{email},#{gender},#{status},#{deptId},#{roleId},#{image},#{remark},#{createTime},#{updateTime})")
    void insert(User user);
    @Select("select id, username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time from user where id=#{id}")
    User getById(Integer id);
/*    @Update("update user set username=#{username},password=#{password},name=#{name},phone=#{phone},email=#{email},gender=#{gender},status=#{status},dept_id=#{deptId},role_id=#{roleId},image=#{image},remark=#{remark},update_time=#{updateTime} where id=#{id}")*/
    void update(User user);
    @Select("select id, username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time from user")
    List<User> getUser();

    List<User> listByRole(String roleLabel);

    List<User> listByDept(Integer deptId);

    void deletes(List<Integer> ids);


    @Select("select u.*, r.label role_label from user u left join role r on u.role_id = r.id where u.username=#{username}")
    User selectbyusername(String  username);
}
